var foo = (n) => {
  // 1   1
  //2    2
  //3    3
  //4    5
  //5    8
  // 得出结论，n阶楼梯的方案数是前两次方案数的和
  // f(x) = f(x-1) + f(x-2)
  let p = 0,q = 0,r = 1
  for(var i = 1;i<=n;i++) {
    p = q
    q = r
    r = p + q
  }
  return r
  
}
console.log(foo(3));